Socket
Socket
Sign inDemoInstall

validate-iri

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    validate-iri

Validates an IRI according to RFC 3987


Version published
Weekly downloads
14K
increased by7.81%
Maintainers
1
Install size
18.8 kB
Created
Weekly downloads
 

Changelog

Source

v1.0.1 - 2022-11-09

Fixed

<a name="v1.0.0"></a>

Readme

Source

Validate IRI

Build status Coverage Status npm version

This tool validates an IRI, either using strict RFC 3987 grammar, or using a faster but less strict pragmatic validation mode. It works in both JavaScript and TypeScript.

Installation

$ npm install validate-iri

or

$ yarn add validate-iri

This package also works out-of-the-box in browsers via tools such as webpack and browserify.

Usage

Multiple validation modes are provided:

  • IriValidationStrategy.Strict: carefully validates the IRI using RFC 3987 grammar. This is the default value.
  • IriValidationStrategy.Pragmatic: quickly validates that the IRI has a valid scheme and does not contain any character forbidden by the N-Triples, Turtle and N3 grammars.
  • IriValidationStrategy.None: does not validate the IRI at all.

Example:

import { validateIri, IriValidationStrategy } from 'validate-iri`
const yourIri = 'https://example.com/john-doe'
validateIri(yourIri, IriValidationStrategy.Pragmatic) // Will throw an error if the IRI is invalid.

Performance

When using strict validation mode, a significant performance overhead should be taken into account. In isolation, strict validation is an order of magnitude slower than pragmatic validation.

When used in a parser such as rdfxml-streaming-parser.js, the performance impact on parsing is the following (GeoSpecies Knowledge Base with 1.8M triples):

  • Strict validation: 12.053s
  • Pragmatic validation: 9.116s
  • No validation: 8.338s

License

This code is released under the MIT license.

Keywords

FAQs

Last updated on 09 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc